package com.huajx.tb.handler;

import com.huajx.core.handler.HandlerAdapter;
import com.huajx.core.message.RequestMessage;
import com.huajx.core.message.ResponseMessage;
import com.huajx.core.util.MessageKit;
import com.huajx.tb.dto.NengLongMessage;
import com.huajx.tb.exception.NengLongTcpException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class QueryStatusHandler extends AbstractNengLongHandler {
    protected final Logger logger = LoggerFactory.getLogger(QueryStatusHandler.class);

    public static final HandlerAdapter me = new QueryStatusHandler();

    @Override
    public ResponseMessage handler(RequestMessage request) {

        render(request, "STATUS");

//        NengLongMessage dto = getMessage(request.getMessage());
//
//        byte[] bytes = dto.getBody();
//
//        if(bytes == null || bytes.length < 32) {
//            throw new NengLongTcpException("消息不完整");
//        }
//
//        String temp = MessageKit.getStr(bytes, 32, bytes.length);
//
//        String response = "JTP" + dto.getSerialNo() + dto.getVersion() + dto.getDeviceId() + "00080A" + "STATUS" + temp;
//
//        request.getSession().write(response);

        return null;
    }


//    @Override
//    public ReplyBody process(LdSession session, SentBody sent) {
//
//        byte[] bytes = sent.getMessage();
//
//        String temp = MessageKit.getStr(bytes, 32, bytes.length);
//////		String date = DateKit.format(new Date(), DateKit.pattern_ymdhms4);
//////		String response = "JTP" + sent.get("serialNo") +sent.get("version")+sent.get("device_id") + "00100C" + date + temp;
//        String response = "JTP" + sent.get("serialNo") + sent.get("version") + sent.get("device_id") + "00080A" + "STATUS" + temp;
//
//
//        logger.info("同步服务器时间响应: {}", response);
//
//        session.getIoSession().write(response);
//
//        return null;
//    }

}
